#include"DB.h"

time_t DetailList::gettime(void) {
	return time;
}
Type DetailList::gettype(void) {
	return type;
}
int DetailList::getresponseType(void) {
	return responseType;
}
int DetailList::getlistId(void) {
	return listId;
}
int DetailList::getroomId(void) {
	return roomId;
}
std::vector<std::string> DetailList::getinfo(void) {
	return info;
}
DetailList::DetailList(int roomId, int listId, std::vector<reqDetail*>req) {
	this->time = std::time(NULL);
	type = Type::RESPONSE;
	responseType = 0;
	this->listId = listId;
	this->roomId = roomId;
	info = setinfo(req);
}

std::vector<std::string> DetailList::setinfo(std::vector<reqDetail*>req) {
	std::vector<std::string> result;
	std::stringstream stream;
	for (int i = 0; i < (int)req.size(); i++) {
		std::string tmp = "";
		stream << req[i]->time;
		std::string time;
		stream >> time;
		stream.clear();

		stream << (int)req[i]->ot;
		std::string ot;
		stream >> ot;
		stream.clear();

		if (req[i]->ot == OptionType::CHANGEW) {
			stream << (int)req[i]->rw;
			std::string rw;
			stream >> rw;
			stream.clear();

			tmp.append(time + " " + ot + " " + rw + "\n");
		}
		else
		{
			stream << (int)req[i]->rt;
			std::string rt;
			stream >> rt;
			stream.clear();

			tmp.append(time + " " + ot + " " + rt + "\n");
		}
		result.push_back(tmp);
	}
	return result;
}